package com.sunday.common.mq.kafka.study.spring.e6_Receiving_Messages_5_Json_Serializer;

import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaHandler;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@KafkaListener(
        id = "myId_4",
        topics = "topic4",
        clientIdPrefix = "TEST4",
        errorHandler = "validationErrorHandler",
        containerFactory = "kafkaJsonSerializerListenerContainerFactory",
        /** https://docs.spring.io/spring-kafka/docs/current/reference/html/#filtering-messages **/
        filter = "recordFilterStrategyImpl"
)
public class MultiListenerBean {

    @KafkaHandler
    public void listen(String foo) {
        log.info("[foo] : {}", foo);
    }

    @KafkaHandler
    public void listen(@Payload @Valid ValidatedClass validatedClass) {
        log.info("[validatedClass] : {}", validatedClass);
    }

    @KafkaHandler
    public void listen(Integer bar) {
        log.info("[bar] : {}", bar);
    }

    @KafkaHandler(isDefault = true)
    public void listenDefault(Object object) {
        log.info("[object] : {}", object);
    }

}
